package it.polimi.travelDreamEJB.travelpacketmanagement;

import it.polimi.travelDreamEJB.basicproductmanagement.Excursion;
import it.polimi.travelDreamEJB.basicproductmanagement.Hotel;
import it.polimi.travelDreamEJB.defaultpacketmanagement.dto.DefaultPacketDTO;
import it.polimi.travelDreamEJB.usermanagement.User;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.*;

/**
 * The persistent class for the default_packet database table.
 * 
 */
@Entity
@Table(name = "default_packet")
@NamedQueries({
	@NamedQuery(name = "DefaultPacket.findAll", query = "SELECT d FROM DefaultPacket d"),
	@NamedQuery(name = "DefaultPacket.findByDestination", query = "SELECT p FROM DefaultPacket p JOIN p.hotel h JOIN p.employee e WHERE h.name LIKE :hotelName AND h.destination LIKE :destination AND e.email LIKE :email")
})
public class DefaultPacket implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "id_default_packet")
	private int idDefaultPacket;

	// bi-directional many-to-one association to User
	@ManyToOne
	@JoinColumn(name = "id_employee")
	private User employee;

	// bi-directional many-to-one association to Hotel
	@ManyToOne
	@JoinColumn(name = "id_hotel")
	private Hotel hotel;

	@ManyToMany
	@JoinTable(name = "default_packet_excursions", joinColumns = { @JoinColumn(name = "id_default_packet", referencedColumnName = "id_default_packet") }, inverseJoinColumns = { @JoinColumn(name = "id_excursion", referencedColumnName = "id_excursion") })
	private List<Excursion> excursions;

	public DefaultPacket() {
	}

	public DefaultPacket(DefaultPacketDTO defaultPacket) {
		this.excursions = new ArrayList<Excursion>();
		this.idDefaultPacket = defaultPacket.getId_default_packet();
		//this.hotel = new Hotel(defaultPacket.getHotel());
		//this.employee = new User(defaultPacket.getUser());
	}

	public int getIdDefaultPacket() {
		return this.idDefaultPacket;
	}

	public void setIdDefaultPacket(int idDefaultPacket) {
		this.idDefaultPacket = idDefaultPacket;
	}

	public Hotel getHotel() {
		return hotel;
	}

	public void setHotel(Hotel hotel) {
		this.hotel = hotel;
	}

	public void setExcursions(List<Excursion> excursions) {
		this.excursions = excursions;
	}

	public List<Excursion> getExcursions() {
		return excursions;
	}

	public User getEmployee() {
		return employee;
	}

	public void setEmployee(User employee) {
		this.employee = employee;
	}

}